﻿Imports System.Data
Imports System.Data.SqlClient

Module moSecu

    Dim retcode, handle_Renamed As Object
    Dim block_index As Short
    Dim uid, hid As Integer
    Dim _buffer As String
    Dim seed As String
    Dim str_Renamed As String
    Dim lblReturn As New Label

    Public Function CheckLicense(ByVal lblDongleKey As Label) As Boolean
        Dim str_ As String
        str_ = "SELECT COUNT(*) FROM People WHERE Active = 1"
        Dim cmd_ As New SqlCommand(str_, gCnnPCE)
        Dim intCount As Integer
        intCount = cmd_.ExecuteScalar
        If intCount > 0 Then
            ' MsgBox(CType(GetDongleStr(), String).ToUpper, MsgBoxStyle.Information)
            lblDongleKey.Text = GetDongleStr()

            If lblDongleKey.Text.ToUpper <> "LEILING1983" Then
                MsgBox("This Version Can Only Support 20 Member", MsgBoxStyle.Exclamation)
                Return False
            Else
                'MsgBox("Welcome !", MsgBoxStyle.Information)
            End If


        End If

        Return True

    End Function

    Public Function GetDongleStr() As String

        Try

        Catch ex As Exception

        End Try
        retcode = RY2_Find()
        If (retcode < 0) Then
            Return False
        End If

        If (retcode = 0) Then
            Return False
        End If

        str_Renamed = "1695016082"

        uid = Val(str_Renamed)

        retcode = RY2_Open(1, uid, hid)
        If (retcode < 0) Then
            Return False
        End If

        handle_Renamed = retcode

        seed = 0
        block_index = Val(seed)
        _buffer = New String(Chr(0), 512)
        retcode = RY2_Read(handle_Renamed, block_index, _buffer)
        If (retcode < 0) Then
            Return False
        End If

        'lblData.Text = buffer
        'If lblData.Text = "leiling1983" Then
        '    Return True
        'End If
        'If buffer.Replace("""", "") = "leiling1983" Then
        '    Return True
        'End If


        RY2_Close(handle_Renamed)
        Return _buffer


    End Function

End Module
